const PrerenderSPAPlugin = require('prerender-spa-plugin')
const Renderer = PrerenderSPAPlugin.PuppeteerRenderer;
const path = require('path')
module.exports = {
    configureWebpack:()=>{
        if (process.env.NODE_ENV !== 'production') return;
        return{
            plugins:[
                new PrerenderSPAPlugin({
                    staticDir: path.join(__dirname, 'dist'),
                    routes: ['/','/about','/product'],
                    renderer:new Renderer({
                        inject : {
                            foo: 'bar'
                        },
                        headless: false,
                        renderAfterDocumentEvent: 'render-event',
                    })
                })
            ]
        }
    },
    chainWebpack: config => {
        config.plugin('html').tap(args => {
                args[0].title = '成都原链科技有限公司-智慧化解决方案专家-二维码溯源-防伪溯源系统'
                return args
            })

    },
    devServer: {
        hot:true,
        open:true,
        proxy: {
            '/api':{
                target:'http://192.168.1.197:8880/plant/',
                changeOrigin:true,
                pathRewrite:{
                    '^/api':''
                }
            }
        }
    },
}
